package com.common.cheng.entities;

import com.common.cheng.enmus.RequestCode;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class Result<T> {

    private Integer code;
    private String message;
    private T data;

    public static <T> Result<T> success(){
        return new Result<>(RequestCode.SUCCESS.getCode(),"success",null);
    }

    public static <T> Result<T> success(T data){
        return new Result<>(RequestCode.SUCCESS.getCode(), "success",data);
    }

    public static <T> Result<T> error(int code,String message){
        return new Result<>(code,message,null);
    }

}
